home *** CD-ROM | disk | FTP | other *** search
/ Digital Background Bonanza / Digital Background Bonanza - Disc 1.iso / pc / DBB1.swf / scripts / __Packages / mx / controls / List.as < prev    next >
Encoding:
Text File  |  2007-03-09  |  5.8 KB  |  201 lines

  1. class mx.controls.List extends mx.controls.listclasses.ScrollSelectList
  2. {
  3.    var border_mc;
  4.    var __labels;
  5.    var setDataProvider;
  6.    var __dataProvider;
  7.    var __maxHPosition;
  8.    var invScrollProps;
  9.    var __width;
  10.    var totalWidth;
  11.    var totalHeight;
  12.    var displayWidth;
  13.    var vScroller;
  14.    var listContent;
  15.    var data;
  16.    var mask_mc;
  17.    var __height;
  18.    var invRowHeight;
  19.    var invLayoutContent;
  20.    var oldVWidth;
  21.    static var symbolOwner = mx.controls.List;
  22.    static var symbolName = "List";
  23.    var className = "List";
  24.    static var version = "2.0.2.126";
  25.    var clipParameters = {rowHeight:1,enabled:1,visible:1,labels:1};
  26.    var scrollDepth = 1;
  27.    var __vScrollPolicy = "on";
  28.    var autoHScrollAble = false;
  29.    function List()
  30.    {
  31.       super();
  32.    }
  33.    function setEnabled(v)
  34.    {
  35.       super.setEnabled(v);
  36.       this.border_mc.backgroundColorName = !v ? "backgroundDisabledColor" : "backgroundColor";
  37.       this.border_mc.invalidate();
  38.    }
  39.    function get labels()
  40.    {
  41.       return this.__labels;
  42.    }
  43.    function set labels(lbls)
  44.    {
  45.       this.__labels = lbls;
  46.       this.setDataProvider(lbls);
  47.    }
  48.    function setVPosition(pos)
  49.    {
  50.       pos = Math.min(this.__dataProvider.length - this.rowCount + this.roundUp,pos);
  51.       pos = Math.max(0,pos);
  52.       super.setVPosition(pos);
  53.    }
  54.    function setHPosition(pos)
  55.    {
  56.       pos = Math.max(Math.min(this.__maxHPosition,pos),0);
  57.       super.setHPosition(pos);
  58.       this.hScroll(pos);
  59.    }
  60.    function setMaxHPosition(pos)
  61.    {
  62.       this.__maxHPosition = pos;
  63.       this.invScrollProps = true;
  64.       this.invalidate();
  65.    }
  66.    function setHScrollPolicy(policy)
  67.    {
  68.       if(policy.toLowerCase() == "auto" && !this.autoHScrollAble)
  69.       {
  70.          return undefined;
  71.       }
  72.       super.setHScrollPolicy(policy);
  73.       if(policy == "off")
  74.       {
  75.          this.setHPosition(0);
  76.          this.setVPosition(Math.min(this.__dataProvider.length - this.rowCount + this.roundUp,this.__vPosition));
  77.       }
  78.    }
  79.    function setRowCount(rC)
  80.    {
  81.       if(isNaN(rC))
  82.       {
  83.          return undefined;
  84.       }
  85.       var _loc2_ = this.getViewMetrics();
  86.       this.setSize(this.__width,this.__rowHeight * rC + _loc2_.top + _loc2_.bottom);
  87.    }
  88.    function layoutContent(x, y, tW, tH, dW, dH)
  89.    {
  90.       this.totalWidth = tW;
  91.       this.totalHeight = tH;
  92.       this.displayWidth = dW;
  93.       var _loc4_ = !(this.__hScrollPolicy == "on" || this.__hScrollPolicy == "auto") ? dW : Math.max(tW,dW);
  94.       super.layoutContent(x,y,_loc4_,dH);
  95.    }
  96.    function modelChanged(eventObj)
  97.    {
  98.       super.modelChanged(eventObj);
  99.       var _loc3_ = eventObj.eventName;
  100.       if(_loc3_ == "addItems" || _loc3_ == "removeItems" || _loc3_ == "updateAll" || _loc3_ == "filterModel")
  101.       {
  102.          this.invScrollProps = true;
  103.          this.invalidate("invScrollProps");
  104.       }
  105.    }
  106.    function onScroll(eventObj)
  107.    {
  108.       var _loc3_ = eventObj.target;
  109.       if(_loc3_ == this.vScroller)
  110.       {
  111.          this.setVPosition(_loc3_.scrollPosition);
  112.       }
  113.       else
  114.       {
  115.          this.hScroll(_loc3_.scrollPosition);
  116.       }
  117.       super.onScroll(eventObj);
  118.    }
  119.    function hScroll(pos)
  120.    {
  121.       this.__hPosition = pos;
  122.       this.listContent._x = - pos;
  123.    }
  124.    function init(Void)
  125.    {
  126.       super.init();
  127.       if(this.labels.length > 0)
  128.       {
  129.          var _loc6_ = new Array();
  130.          var _loc3_ = 0;
  131.          while(_loc3_ < this.labels.length)
  132.          {
  133.             _loc6_.addItem({label:this.labels[_loc3_],data:this.data[_loc3_]});
  134.             _loc3_ = _loc3_ + 1;
  135.          }
  136.          this.setDataProvider(_loc6_);
  137.       }
  138.       this.__maxHPosition = 0;
  139.    }
  140.    function createChildren(Void)
  141.    {
  142.       super.createChildren();
  143.       this.listContent.setMask(this.mask_mc);
  144.       this.border_mc.move(0,0);
  145.       this.border_mc.setSize(this.__width,this.__height);
  146.    }
  147.    function getRowCount(Void)
  148.    {
  149.       var _loc2_ = this.getViewMetrics();
  150.       return this.__rowCount != 0 ? this.__rowCount : Math.ceil((this.__height - _loc2_.top - _loc2_.bottom) / this.__rowHeight);
  151.    }
  152.    function size(Void)
  153.    {
  154.       super.size();
  155.       this.configureScrolling();
  156.       var _loc3_ = this.getViewMetrics();
  157.       this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  158.    }
  159.    function draw(Void)
  160.    {
  161.       if(this.invRowHeight)
  162.       {
  163.          this.invScrollProps = true;
  164.          super.draw();
  165.          this.listContent.setMask(this.mask_mc);
  166.          this.invLayoutContent = true;
  167.       }
  168.       if(this.invScrollProps)
  169.       {
  170.          this.configureScrolling();
  171.          delete this.invScrollProps;
  172.       }
  173.       if(this.invLayoutContent)
  174.       {
  175.          var _loc3_ = this.getViewMetrics();
  176.          this.layoutContent(_loc3_.left,_loc3_.top,this.__width + this.__maxHPosition,this.totalHeight,this.__width - _loc3_.left - _loc3_.right,this.__height - _loc3_.top - _loc3_.bottom);
  177.       }
  178.       super.draw();
  179.    }
  180.    function configureScrolling(Void)
  181.    {
  182.       var _loc2_ = this.__dataProvider.length;
  183.       if(this.__vPosition > Math.max(0,_loc2_ - this.getRowCount() + this.roundUp))
  184.       {
  185.          this.setVPosition(Math.max(0,Math.min(_loc2_ - this.getRowCount() + this.roundUp,this.__vPosition)));
  186.       }
  187.       var _loc3_ = this.getViewMetrics();
  188.       var _loc4_ = this.__hScrollPolicy == "off" ? this.__width - _loc3_.left - _loc3_.right : this.__maxHPosition + this.__width - _loc3_.left - _loc3_.right;
  189.       if(_loc2_ == undefined)
  190.       {
  191.          _loc2_ = 0;
  192.       }
  193.       this.setScrollProperties(_loc4_,1,_loc2_,this.__rowHeight);
  194.       if(this.oldVWidth != _loc4_)
  195.       {
  196.          this.invLayoutContent = true;
  197.       }
  198.       this.oldVWidth = _loc4_;
  199.    }
  200. }
  201.